/**
 * 气象局API Mock地址配置
 * 用于开发环境的Mock数据服务
 */

import { MOCK_CONFIG } from '.'
// import { MOCK_CONFIG } from '@/constants'

// APIFOX Mock服务基础地址
export const MOCK_BASE_URL = 'http://127.0.0.1:4523'
export const MOCK_PROJECT_ID = 'm2/6988617-6706178-default'
export const MOCK_PROJECT_ID_M1 = 'm1/6988617-6706178-default'

// 气象局API Mock地址配置
export const WEATHER_API_MOCK = {
  // 单个场站每日预测
  SINGLE_STATION_DAILY_FORECAST: {
    url: `${MOCK_BASE_URL}/${MOCK_PROJECT_ID}/345535317?apifoxApiId=345535317`,
    method: 'GET',
    description: '单个场站每日预测',
    mockId: '345535317'
  },

  // 多个场站每日预测
  MULTI_STATION_DAILY_FORECAST: {
    url: `${MOCK_BASE_URL}/${MOCK_PROJECT_ID}/339599228?apifoxApiId=339599228`,
    method: 'GET', 
    description: '多个场站每日预测',
    mockId: '339599228'
  },

  // 获取25个场站的预报辐射数据
  STATION_RADIATION_FORECAST: {
    url: `${MOCK_BASE_URL}/${MOCK_PROJECT_ID_M1}/api_proxy/meteoApi/meteodata/getStationRadiationByGrid`,
    method: 'POST',
    description: '获取25个场站的预报辐射数据',
    mockId: 'api_proxy_meteoApi_meteodata_getStationRadiationByGrid'
  },

  // 飞戈爬取-实时数据历史记录
  REALTIME_DATA_HISTORY: {
    url: `${MOCK_BASE_URL}/${MOCK_PROJECT_ID}/346079498?apifoxApiId=346079498`,
    method: 'GET',
    description: '飞戈爬取-实时数据历史记录',
    mockId: '346079498'
  },

  // 公服中心风速数据站点反演
  WIND_SPEED_STATION_DATA: {
    url: `${MOCK_BASE_URL}/${MOCK_PROJECT_ID_M1}/api_proxy/dongmeng/sk/getWindReloadSign?apifoxApiId=346068950`,
    method: 'GET',
    description: '公服中心风速数据站点反演',
    mockId: '346068950'
  },

  // 桂冠获取Token
  GUIGUAN_TOKEN: {
    url: `${MOCK_BASE_URL}/${MOCK_PROJECT_ID}/340211893?apifoxApiId=340211893`,
    method: 'GET',
    description: '桂冠获取Token',
    mockId: '340211893'
  }
}

// Mock API路径映射（用于services.ts中的条件判断）
export enum MOCK_API_PATHS {
  // 单个场站每日预测
  singleStationForecast = '/345535317?apifoxApiId=345535317',
  
  // 多个场站每日预测
  multiStationForecast = '/339599228?apifoxApiId=339599228',
  
  // 25个场站预报辐射数据
  stationRadiation = '/api_proxy/meteoApi/meteodata/getStationRadiationByGrid',
  
  // 飞戈爬取实时数据历史
  realtimeHistory = '/346079498?apifoxApiId=346079498',
  
  // 公服中心风速数据
  windSpeedData = '/api_proxy/dongmeng/sk/getWindReloadSign?apifoxApiId=346068950',
  
  // 桂冠Token
  guiguanToken = '/340211893?apifoxApiId=340211893'
}

// 生产环境API路径映射
export enum PRODUCTION_API_PATHS {
  // 单个场站每日预测
  singleStationForecast = '/api_proxy/WindPower/Electric/getElectricAndPower',
  
  // 多个场站每日预测
  multiStationForecast = '/business/multi-station-forecast',
  
  // 25个场站预报辐射数据
  stationRadiation = '/api_proxy/meteoApi/meteodata/getStationRadiationByGrid',
  
  // 飞戈爬取实时数据历史
  realtimeHistory = '/feige/realtime-history',
  
  // 公服中心风速数据
  windSpeedData = '/api_proxy/dongmeng/sk/getWindReloadSign',
  
  // 桂冠Token
  guiguanToken = '/dam/service/auth'
}

// 获取API路径的工具函数
export const getApiPath = (apiKey: ApiPathKeys & ProductionApiPathKeys, useMock: boolean = MOCK_CONFIG.ENABLED): string => {
  return useMock ? MOCK_API_PATHS[apiKey] : PRODUCTION_API_PATHS[apiKey]
}

// 获取完整Mock URL的工具函数
export const getMockUrl = (apiKey: keyof typeof WEATHER_API_MOCK): string => {
  return WEATHER_API_MOCK[apiKey].url
}

// 导出所有Mock配置
export default {
  MOCK_BASE_URL,
  MOCK_PROJECT_ID,
  MOCK_PROJECT_ID_M1,
  WEATHER_API_MOCK,
  MOCK_API_PATHS,
  PRODUCTION_API_PATHS,
  getApiPath,
  getMockUrl
}

// API配置类型定义
export interface MockApiConfig {
  url: string
  method: 'GET' | 'POST' | 'PUT' | 'DELETE'
  description: string
  mockId: string
}

export type WeatherApiMockKeys = keyof typeof WEATHER_API_MOCK
export type ApiPathKeys = keyof typeof MOCK_API_PATHS
export type ProductionApiPathKeys = keyof typeof PRODUCTION_API_PATHS